const App = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentData: "0",
    hotSwiperImage: [
      'https://t00img.yangkeduo.com/goods/2019-11-20/0c7cbcf6a07241f8ac9feea5002a498e.jpeg?imageMogr2/strip%7CimageView2/2/w/750/q/80',
      'https://t16img.yangkeduo.com/img_check/2019-12-09/9d2e590a552038e3ea9debe3f8e2caf5.jpg?imageMogr2/strip%7CimageView2/2/w/750/q/80',
      'https://t16img.yangkeduo.com/pdd_oms/2019-06-19/922813ff92531531bb46ede65212909a.jpeg?imageMogr2/strip%7CimageView2/2/w/750/q/80',
      'https://t16img.yangkeduo.com/img_check/2019-12-02/486a05a8af096ddd17767288bebb1d36.jpg?imageMogr2/strip%7CimageView2/2/w/750/q/80',
      'https://t16img.yangkeduo.com/img_check/2019-12-09/55bbf119386d2efc1912a76d218cba13.jpg?imageMogr2/strip%7CimageView2/2/w/750/q/80',
      'https://t16img.yangkeduo.com/img_check/2019-12-03/64598a52b79432756558115c24adea0e.jpg?imageMogr2/sharpen/50/strip%7CimageView2/2/w/750/q/80/format/webp',
      'https://t16img.yangkeduo.com/pdd_oms/2019-06-30/fcbe21a01dfdbbf2c1889ffae4a7627f.jpg?imageMogr2/strip%7CimageView2/2/w/750/q/80'
    ],
    scrollBarLeft: "0",
    testData: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      testData: App.globalData.productInfor
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  scroll(e) {
    this.setData({
      scrollBarLeft: e.detail.scrollLeft
    })
  },

  bindchange: function(e) {
    const that = this;
    that.setData({
      currentData: e.detail.current
    })
    wx.pageScrollTo({
      scrollTop: 0,
      duration: 300
    })
  },

  //点击切换，滑块index赋值
  checkCurrent: function(e) {
    const that = this;
    if (that.data.currentData === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentData: e.target.dataset.current
      })
    }
    wx.pageScrollTo({
      scrollTop: 0,
      duration: 300
    })
  },

  goShop: function(event) {
    App.globalData.productIndex = event.currentTarget.id;
    
    wx.navigateTo({
      url: '../shop/shop'
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})